/*
 * @lc app=leetcode.cn id=171 lang=javascript
 *
 * [171] Excel 表列序号
 */

// @lc code=start
/**
 * @param {string} columnTitle
 * @return {number}
 */
var titleToNumber = function(columnTitle) {
  let res = 0;
  for(let i = 0; i < columnTitle.length; i++) {
    const ch = columnTitle[i];
    const cur = ch.charCodeAt() - 'A'.charCodeAt() + 1;
    res += cur * Math.pow(26, columnTitle.length - i - 1);
  }
  return res;
};
// @lc code=end

